package com.cyzy.service;

import com.cyzy.mapper.PersonalMapper;
import com.cyzy.util.OrcUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class PersonalService {
    @Autowired
    private PersonalMapper personalMapper;
    @Autowired
    private OrcUtil ocrUtil;

    public int updateRealName(String path,String id) throws Exception {
        HashMap<String,String> map = ocrUtil.recognition(path);
        if (map == null){
            throw  new RuntimeException("没识别到身份信息");
        }
        String realName = map.get("name");
        String idCard = map.get("idNumber");
        System.out.println(realName+idCard);
        int i = personalMapper.updateRealName(realName, idCard, id);
        if (i == 0){
            throw  new RuntimeException("更新失败");
        }
        return i;
    }
}
